package com.example.shiwu.util;

import java.util.ArrayList;

public class SwitchBoxUtil {
    public static String boxIdToSpilt(ArrayList<String> idlis, int box){
        ArrayList<String> lisId = new ArrayList<String>();
        String id = "";

        if(idlis.size()>0){

            for (int i = 0; i < idlis.size(); i++) {
                id = idlis.get(i).toString();
                if(id.contains("0")){
                    id = id.toString().substring(1);
                    lisId.add(id);
                }else {
                    lisId.add(id);
                }
            }
        }
        String boxId = "";
        if(box<=12){
            boxId = lisId.get(0) + "," + box;
            System.out.println("--------------------- <12 -----------------------" +boxId);
        }else {
            int a = box / 12;
            int b = box % 12;
            if(b==0){
                b = 12;
            }
            if(a == lisId.size()){
                a = a-1;
            }
            int aa = Integer.parseInt(lisId.get(a));
            boxId = String.valueOf(aa)+","+String.valueOf(b);
            System.out.println("--------------------- >12 -----------------------" +boxId);
        }
        return boxId;
    }

    public static void main(String[] args) {
        ArrayList<String> lisId = new ArrayList<String>();
        lisId.add("01");
        lisId.add("02");
        //lisId.add("03");
        //String box = boxIdToSpilt(lisId,14);
        String box2 = boxIdToSpilt(lisId,25);
//        String box3 = boxIdToSpilt(lisId,34);
//        String box4 = boxIdToSpilt(lisId,44);
    }
}
